6  Dependent-Samples t-tests

Sample Problems

6.1 About

the dependent-samples t-Test problems use the RamdomData class which requires:

  • the groups variable set to 2: groups = 2
  • the sample size per group - all groups will have the same sample size
  • a call to the dependent_samples_t_test() method

In these sample problems, the per-group sample size is randomly set between 5 and 15. An example funciton call is included below

sample_size = random.randint(5,15)
RandomData(groups = 2, n = sample_size).dependent_samples_t_test()

6.2 Problem 1

Given the following within-subjects data, is \(M_D\) significantly different from \({0}\)? Use a \({2}\) tailed-test with \(\alpha = {0.05}\)

ID A B
1 14 13
2 13 11
3 19 18
4 20 17
5 16 13
6 15 14
7 17 17
8 19 14
9 19 20


Summary statistics for these data:
\[M_A = {16.89}, M_B = {15.22}\] \[n = {9}\]

State the Hypotheses
\[H_0: \mu_D = 0\] \[H_1: \mu_D \ne 0\]


The decision criteria:

\(t_{crit} = \pm{2.31}, \alpha_{two-tailed} = {0.05}, df = {8}\)

Calculating the difference scores \(D = X_B - X_A\)

ID A B D
1 14 13 -1
2 13 11 -2
3 19 18 -1
4 20 17 -3
5 16 13 -3
6 15 14 -1
7 17 17 0
8 19 14 -5
9 19 20 1


Calculate the Mean of the Difference Scores \[M_D = \frac{\Sigma D}{n}\]
\[M_D = \frac{-15}{9}\]
\[M_D = {-1.67}\]

Create a column for the squared difference scores \(D^2\)

ID A B D D^2
1 14 13 -1 1
2 13 11 -2 4
3 19 18 -1 1
4 20 17 -3 9
5 16 13 -3 9
6 15 14 -1 1
7 17 17 0 0
8 19 14 -5 25
9 19 20 1 1


New Summary statistics for the difference scores:
\[M_D = {-1.67}, \quad \Sigma{D} = {-15}, \quad \Sigma{D^2} = {51}\]


Calculate SS of the difference scores
\[SS_D = \Sigma D^2 - \frac{(\Sigma D)^2}{n}\]
\[SS_D = {51} - \frac{225}{9}\]
\[SS_D = {51} - {25.0}\]
\[SS_D = {26.0}\]

Calculate the variance of the difference scores
\[s_D^2 = \frac{SS_D}{df}\]
\[s_D^2 = \frac{26.0}{8}\]
\[s_D^2 = {3.25}\]

Calculate the estimated standard error of the difference scores
\[s_{M_D} = \sqrt{\frac{s^2}{n}}\]
\[s_{M_D} = \sqrt{\frac{3.25}{9}}\]
\[s_{M_D} = \sqrt{0.36}\]
\[s_{M_D} = {0.6}\]

Calculate \(t_{obt}\)
\[t_{obt} = {\frac{M_D - \mu_D}{s_{M_D}}}\]
\[t_{obt} = \frac{-1.67 - 0}{0.6}\]
\[t_{obt} = \frac{-1.67}{0.6}\]
\[t_{obt} = {-2.78}\]

Calculating Cohen’s d
\[d = \frac{M_D}{\sqrt{s^2}}\]
\[d = \frac{-1.67}{{{\sqrt{3.25}}}}\]
\[d = \frac{-1.67}{1.8}\]
\[d = {-0.93}\]

The results:

reject the null hypothesis, results are significant,
t(8) = -2.78, p < 0.05, d = -0.93

6.3 Problem 2

Given the following within-subjects data, is \(M_D\) significantly different from \({0}\)? Use a \({2}\) tailed-test with \(\alpha = {0.05}\)

ID A B
1 15 27
2 22 16
3 18 27
4 24 26
5 10 20
6 17 26
7 19 7
8 24 30
9 22 27
10 15 23
11 15 23
12 17 24
13 16 37


Summary statistics for these data:
\[M_A = {18.0}, M_B = {24.08}\] \[n = {13}\]

State the Hypotheses
\[H_0: \mu_D = 0\] \[H_1: \mu_D \ne 0\]


The decision criteria:

\(t_{crit} = \pm{2.18}, \alpha_{two-tailed} = {0.05}, df = {12}\)

Calculating the difference scores \(D = X_B - X_A\)

ID A B D
1 15 27 12
2 22 16 -6
3 18 27 9
4 24 26 2
5 10 20 10
6 17 26 9
7 19 7 -12
8 24 30 6
9 22 27 5
10 15 23 8
11 15 23 8
12 17 24 7
13 16 37 21


Calculate the Mean of the Difference Scores \[M_D = \frac{\Sigma D}{n}\]
\[M_D = \frac{79}{13}\]
\[M_D = {6.08}\]

Create a column for the squared difference scores \(D^2\)

ID A B D D^2
1 15 27 12 144
2 22 16 -6 36
3 18 27 9 81
4 24 26 2 4
5 10 20 10 100
6 17 26 9 81
7 19 7 -12 144
8 24 30 6 36
9 22 27 5 25
10 15 23 8 64
11 15 23 8 64
12 17 24 7 49
13 16 37 21 441


New Summary statistics for the difference scores:
\[M_D = {6.08}, \quad \Sigma{D} = {79}, \quad \Sigma{D^2} = {1269}\]


Calculate SS of the difference scores
\[SS_D = \Sigma D^2 - \frac{(\Sigma D)^2}{n}\]
\[SS_D = {1269} - \frac{6241}{13}\]
\[SS_D = {1269} - {480.08}\]
\[SS_D = {788.92}\]

Calculate the variance of the difference scores
\[s_D^2 = \frac{SS_D}{df}\]
\[s_D^2 = \frac{788.92}{12}\]
\[s_D^2 = {65.74}\]

Calculate the estimated standard error of the difference scores
\[s_{M_D} = \sqrt{\frac{s^2}{n}}\]
\[s_{M_D} = \sqrt{\frac{65.74}{13}}\]
\[s_{M_D} = \sqrt{5.06}\]
\[s_{M_D} = {2.25}\]

Calculate \(t_{obt}\)
\[t_{obt} = {\frac{M_D - \mu_D}{s_{M_D}}}\]
\[t_{obt} = \frac{6.08 - 0}{2.25}\]
\[t_{obt} = \frac{6.08}{2.25}\]
\[t_{obt} = {2.7}\]

Calculating Cohen’s d
\[d = \frac{M_D}{\sqrt{s^2}}\]
\[d = \frac{6.08}{{{\sqrt{65.74}}}}\]
\[d = \frac{6.08}{8.11}\]
\[d = {0.75}\]

The results:

reject the null hypothesis, results are significant,
t(12) = 2.7, p < 0.05, d = 0.75

6.4 Problem 3

Given the following within-subjects data, is \(M_D\) significantly different from \({0}\)? Use a \({2}\) tailed-test with \(\alpha = {0.01}\)

ID A B
1 18 19
2 14 22
3 15 24
4 16 17
5 16 21
6 16 27
7 17 26
8 15 21
9 13 25
10 13 23
11 12 21
12 13 21
13 15 22
14 10 21


Summary statistics for these data:
\[M_A = {14.5}, M_B = {22.14}\] \[n = {14}\]

State the Hypotheses
\[H_0: \mu_D = 0\] \[H_1: \mu_D \ne 0\]


The decision criteria:

\(t_{crit} = \pm{3.01}, \alpha_{two-tailed} = {0.01}, df = {13}\)

Calculating the difference scores \(D = X_B - X_A\)

ID A B D
1 18 19 1
2 14 22 8
3 15 24 9
4 16 17 1
5 16 21 5
6 16 27 11
7 17 26 9
8 15 21 6
9 13 25 12
10 13 23 10
11 12 21 9
12 13 21 8
13 15 22 7
14 10 21 11


Calculate the Mean of the Difference Scores \[M_D = \frac{\Sigma D}{n}\]
\[M_D = \frac{107}{14}\]
\[M_D = {7.64}\]

Create a column for the squared difference scores \(D^2\)

ID A B D D^2
1 18 19 1 1
2 14 22 8 64
3 15 24 9 81
4 16 17 1 1
5 16 21 5 25
6 16 27 11 121
7 17 26 9 81
8 15 21 6 36
9 13 25 12 144
10 13 23 10 100
11 12 21 9 81
12 13 21 8 64
13 15 22 7 49
14 10 21 11 121


New Summary statistics for the difference scores:
\[M_D = {7.64}, \quad \Sigma{D} = {107}, \quad \Sigma{D^2} = {969}\]


Calculate SS of the difference scores
\[SS_D = \Sigma D^2 - \frac{(\Sigma D)^2}{n}\]
\[SS_D = {969} - \frac{11449}{14}\]
\[SS_D = {969} - {817.79}\]
\[SS_D = {151.21}\]

Calculate the variance of the difference scores
\[s_D^2 = \frac{SS_D}{df}\]
\[s_D^2 = \frac{151.21}{13}\]
\[s_D^2 = {11.63}\]

Calculate the estimated standard error of the difference scores
\[s_{M_D} = \sqrt{\frac{s^2}{n}}\]
\[s_{M_D} = \sqrt{\frac{11.63}{14}}\]
\[s_{M_D} = \sqrt{0.83}\]
\[s_{M_D} = {0.91}\]

Calculate \(t_{obt}\)
\[t_{obt} = {\frac{M_D - \mu_D}{s_{M_D}}}\]
\[t_{obt} = \frac{7.64 - 0}{0.91}\]
\[t_{obt} = \frac{7.64}{0.91}\]
\[t_{obt} = {8.4}\]

Calculating Cohen’s d
\[d = \frac{M_D}{\sqrt{s^2}}\]
\[d = \frac{7.64}{{{\sqrt{11.63}}}}\]
\[d = \frac{7.64}{3.41}\]
\[d = {2.24}\]

The results:

reject the null hypothesis, results are significant,
t(13) = 8.4, p < 0.01, d = 2.24

6.5 Problem 4

Given the following within-subjects data, is \(M_D\) significantly different from \({0}\)? Use a \({2}\) tailed-test with \(\alpha = {0.01}\)

ID A B
1 42 44
2 38 37
3 41 43
4 41 39
5 41 41
6 41 28
7 35 40
8 43 44
9 47 42


Summary statistics for these data:
\[M_A = {41.0}, M_B = {39.78}\] \[n = {9}\]

State the Hypotheses
\[H_0: \mu_D = 0\] \[H_1: \mu_D \ne 0\]


The decision criteria:

\(t_{crit} = \pm{3.36}, \alpha_{two-tailed} = {0.01}, df = {8}\)

Calculating the difference scores \(D = X_B - X_A\)

ID A B D
1 42 44 2
2 38 37 -1
3 41 43 2
4 41 39 -2
5 41 41 0
6 41 28 -13
7 35 40 5
8 43 44 1
9 47 42 -5


Calculate the Mean of the Difference Scores \[M_D = \frac{\Sigma D}{n}\]
\[M_D = \frac{-11}{9}\]
\[M_D = {-1.22}\]

Create a column for the squared difference scores \(D^2\)

ID A B D D^2
1 42 44 2 4
2 38 37 -1 1
3 41 43 2 4
4 41 39 -2 4
5 41 41 0 0
6 41 28 -13 169
7 35 40 5 25
8 43 44 1 1
9 47 42 -5 25


New Summary statistics for the difference scores:
\[M_D = {-1.22}, \quad \Sigma{D} = {-11}, \quad \Sigma{D^2} = {233}\]


Calculate SS of the difference scores
\[SS_D = \Sigma D^2 - \frac{(\Sigma D)^2}{n}\]
\[SS_D = {233} - \frac{121}{9}\]
\[SS_D = {233} - {13.44}\]
\[SS_D = {219.56}\]

Calculate the variance of the difference scores
\[s_D^2 = \frac{SS_D}{df}\]
\[s_D^2 = \frac{219.56}{8}\]
\[s_D^2 = {27.44}\]

Calculate the estimated standard error of the difference scores
\[s_{M_D} = \sqrt{\frac{s^2}{n}}\]
\[s_{M_D} = \sqrt{\frac{27.44}{9}}\]
\[s_{M_D} = \sqrt{3.05}\]
\[s_{M_D} = {1.75}\]

Calculate \(t_{obt}\)
\[t_{obt} = {\frac{M_D - \mu_D}{s_{M_D}}}\]
\[t_{obt} = \frac{-1.22 - 0}{1.75}\]
\[t_{obt} = \frac{-1.22}{1.75}\]
\[t_{obt} = {-0.7}\]

Calculating Cohen’s d
\[d = \frac{M_D}{\sqrt{s^2}}\]
\[d = \frac{-1.22}{{{\sqrt{27.44}}}}\]
\[d = \frac{-1.22}{5.24}\]
\[d = {-0.23}\]

The results:

fail to reject the null hypothesis, results not significant,
t(8) = -0.7, p > 0.01, d = -0.23

6.6 Problem 5

Given the following within-subjects data, is \(M_D\) significantly different from \({0}\)? Use a \({2}\) tailed-test with \(\alpha = {0.01}\)

ID A B
1 47 40
2 43 53
3 35 45
4 38 55
5 40 43
6 41 46
7 32 44
8 39 40
9 38 40


Summary statistics for these data:
\[M_A = {39.22}, M_B = {45.11}\] \[n = {9}\]

State the Hypotheses
\[H_0: \mu_D = 0\] \[H_1: \mu_D \ne 0\]


The decision criteria:

\(t_{crit} = \pm{3.36}, \alpha_{two-tailed} = {0.01}, df = {8}\)

Calculating the difference scores \(D = X_B - X_A\)

ID A B D
1 47 40 -7
2 43 53 10
3 35 45 10
4 38 55 17
5 40 43 3
6 41 46 5
7 32 44 12
8 39 40 1
9 38 40 2


Calculate the Mean of the Difference Scores \[M_D = \frac{\Sigma D}{n}\]
\[M_D = \frac{53}{9}\]
\[M_D = {5.89}\]

Create a column for the squared difference scores \(D^2\)

ID A B D D^2
1 47 40 -7 49
2 43 53 10 100
3 35 45 10 100
4 38 55 17 289
5 40 43 3 9
6 41 46 5 25
7 32 44 12 144
8 39 40 1 1
9 38 40 2 4


New Summary statistics for the difference scores:
\[M_D = {5.89}, \quad \Sigma{D} = {53}, \quad \Sigma{D^2} = {721}\]


Calculate SS of the difference scores
\[SS_D = \Sigma D^2 - \frac{(\Sigma D)^2}{n}\]
\[SS_D = {721} - \frac{2809}{9}\]
\[SS_D = {721} - {312.11}\]
\[SS_D = {408.89}\]

Calculate the variance of the difference scores
\[s_D^2 = \frac{SS_D}{df}\]
\[s_D^2 = \frac{408.89}{8}\]
\[s_D^2 = {51.11}\]

Calculate the estimated standard error of the difference scores
\[s_{M_D} = \sqrt{\frac{s^2}{n}}\]
\[s_{M_D} = \sqrt{\frac{51.11}{9}}\]
\[s_{M_D} = \sqrt{5.68}\]
\[s_{M_D} = {2.38}\]

Calculate \(t_{obt}\)
\[t_{obt} = {\frac{M_D - \mu_D}{s_{M_D}}}\]
\[t_{obt} = \frac{5.89 - 0}{2.38}\]
\[t_{obt} = \frac{5.89}{2.38}\]
\[t_{obt} = {2.47}\]

Calculating Cohen’s d
\[d = \frac{M_D}{\sqrt{s^2}}\]
\[d = \frac{5.89}{{{\sqrt{51.11}}}}\]
\[d = \frac{5.89}{7.15}\]
\[d = {0.82}\]

The results:

fail to reject the null hypothesis, results not significant,
t(8) = 2.47, p > 0.01, d = 0.82